package edu.zjut.sjq.controller;

import edu.zjut.sjq.bean.Comment;
import edu.zjut.sjq.bean.Result;
import edu.zjut.sjq.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by sue on 2017/3/18.
 */
@Controller
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 添加评论
     * @param comment
     * @return
     */
    @RequestMapping(value = "/add",produces="application/json")
    @ResponseBody
    public Result addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }

    /**
     * 获取评论
     * @param articleId
     * @return
     */
    @RequestMapping("/get")
    @ResponseBody
    public List<Comment> getComment(@RequestParam("articleId") Integer articleId){
        return commentService.getComment(articleId,null);
    }
}
